

#!/usr/bin/python

# 计算是否是瑞年

def leap_year(year):
    if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
        return True
    else:
        return False


# 计算每个年份每月的天数
def getMothday(year, month):
    days = 31
    if month == 2:
        if leap_year(year):
            days = 29
        else:
            days = 28
    elif month == 4 or month == 6 or month == 9 or month == 11:
        days = 30

    # print('这个月有:',days)
    return days

getMothday(2020,2)


def getTotalDays(year,month):#计算星期
    totalDays=0
    for i in range(1990,year):
        if leap_year(i):
            totalDays += 366
        else:
            totalDays += 365
    for i in range(1,month):
        totalDays +=getMothday(year,i)

    # 737424
    # print(totalDays)
    return totalDays

getTotalDays(2020,5)

# year = int(input('年份'))
# month = int(input('月'))

year =2018
month = 6
iCount = 0
print( "一\t二\t三\t四\t五\t六\t日")
i=1
for i in range(getTotalDays(year,month)%7):
        print (end='\t')
        iCount+=1
for day in range(1,getMothday(year,month)+1):
        print( day,end='\t'),
        iCount +=1
        if iCount%7 == 0 :
            print ('')